<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<link rel="stylesheet" th:href="@{/assets/css/colorbox.css}"/>
<link rel="stylesheet" th:href="@{/assets/css/fixedColumns.dataTables.css}"/>
<link rel="stylesheet" th:href="@{/assets/css/jquery.dataTables.min.css}"/>
<head th:include="fragments/head::header"/>
<style type="text/css">
    .error {
        color: #F00
    }

    .DTFC_LeftBodyLiner {
        height: 910px ! important;
    }
</style>
<body>
<div th:include="fragments/top::top"></div>
<div class="main-container" id="main-container">
    <div class="main-container-inner">
        <div th:include="fragments/left::left" class="sidebar" id="sidebar"></div>
        <div class="main-content">

            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="row">
                            <div class="col-xs-12">
                                <h3 class="header smaller lighter blue">查看所有结案学生列表</h3>

                                <input type="hidden" id="planCollegeId"
                                       th:value="${planCollegeId}"/>

                                <div class="table-header">
                                    <form class="form-inline">
                                        <!--<div class="form-group">-->

                                            <!--<label for="sNo">院校名称：</label>-->
                                            <!--<input type="text" id="collegeName" class="form-control input-sm"-->
                                                   <!--placeholder="" style="width:60px;" onkeyup="changeTable()"/>-->
                                            <!--<label for="sName">专业名称：</label>-->
                                            <!--<input type="text" id="majorName" class="form-control input-sm" placeholder=""-->
                                                   <!--style="width:60px;" onkeyup="changeTable()"/>-->
                                        <!--</div>-->


                                        <div class="form-group">
                                            <label for="sNo">学号：</label>
                                            <input type="text" id="sNo" class="form-control input-sm"
                                                   placeholder="" style="width:60px;" onkeyup="changeTable()"/>
                                            <label for="sName">姓名：</label>
                                            <input type="text" id="sName" class="form-control input-sm" placeholder=""
                                                   style="width:60px;" onkeyup="changeTable()"/>

                                        </div>
                                        <div class="form-group">
                                            <label for="selectNationSearch">留学国家：</label>
                                            <select class="form-control input-sm" id="selectNationSearch"
                                                    style="width:150px;height:27px;margin:5px 0;" onchange="changeTable()"
                                                    data-placeholder="--请选择留学国家--">
                                                <option></option>
                                                <option th:each="country:${countryInfoList}" th:value="${country.id}"
                                                        th:text="${country.countryName}"></option>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label for="sStatus">结案原因：</label>
                                            <select type="" class="form-control input-sm" id="sStatus"
                                                    style="width:100px;" onchange="changeTable()">
                                                <option value="">请选择</option>
                                                <option value="1">单文书结案</option>
                                                <option value="2">单申请结案</option>
                                                <option value="3">其他</option>
                                                <option value="4">自动结案</option>
                                                <option value="5">退费结案</option>
                                                <option value="6">套磁结案</option>
                                                <option value="6">增值服务结案</option>
                                            </select>
                                        </div>
                                        <button type="button" id="query" class="btn btn-success"
                                                onclick="changeTable()">查询
                                        </button>
                                        <button  class="btn btn-warning">清空</button>
                                    </form>
                                </div>
                                <div class="table-responsive">
                                    <table id="sample-table-2" class="table table-striped table-bordered table-hover"
                                           style="white-space: nowrap;">
                                        <thead>
                                        <tr>
                                            <th>学号</th>
                                            <th>姓名</th>
                                            <th>国家</th>
                                            <th>咨询顾问</th>
                                            <th>文签顾问</th>
                                            <th>签约日期</th>
                                            <th>结案类型</th>
                                            <th>是否审批</th>
                                            <th>详情</th>
                                        </tr>
                                        </thead>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </div>
            <!-- /.page-content -->
        </div>

        <div th:include="fragments/bottom::bottom"></div>
    </div>

    <a href="#" id="btn-scroll-up"
       class="btn-scroll-up btn btn-sm btn-inverse"> <i
            class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div>
<!-- /.main-container -->

<!-- Modal备注 -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content"></div>
    </div>
</div>
<div th:include="fragments/js::js"></div>

<script th:src="@{/assets/js/jquery.validate.min.js}"></script>
<script th:src="@{/assets/js/jquery.validate.zh-CN.js}"></script>
<!-- page specific plugin scripts -->
<script charset="UTF-8" th:src="@{/assets/js/1.10.15/jquery.dataTables.min.js}"></script>
<script charset="UTF-8" th:src="@{/assets/js/jquery.dataTables.bootstrap.js}"></script>
<script charset="UTF-8" th:src="@{/assets/js/dataTables.fixedColumns.js}"></script>
<script th:src="@{/assets/js/temp.js}" charset="UTF-8"></script>
<!--<script th:src="@{/business/followService/followService.js}" charset="UTF-8"></script>-->
<!--图片查看器-->
<script th:src="@{/assets/js/jquery.colorbox-min.js}"></script>
<script th:src="@{/layer/layer.js}"></script>
<script type="text/javascript">

    /*<![CDATA[*/
    var currentUser = $("#currentUser").val();
    var oTable1;
    jQuery(function ($) {
        oTable1 = $('#sample-table-2').dataTable({
            "bFilter" : false,//是否使用搜索
            "bProcessing" : true,
            "bDeferRender" : true,//
            "sPaginationType" : "bs_normal",//分页样式
            "bRetrieve" : true,//是否调用后台
            "bServerSide" : true,//是否以后台分页
            "bAutoWidth": true,
//            "scrollX": true,
//            "autoWidth":true,
//            "fixedColumns": { //固定列的配置项
//                "leftColumns": 2, //固定左边第一列
//            },
            "sAjaxSource": "/management/checkAllSettleList",//请求路径
            "fnServerData": function (sSource, aoData, fnCallback) {
                aoData.push(
//                    {name: "collegeName", value: $("#collegeName").val() == "" ? null : $.trim($("#collegeName").val())},
//                    {name: "majorName",   value: $("#majorName").val() == "" ? null : $.trim($("#majorName").val())},
                    {name: "nationId", value: $("#selectNationSearch").find("option:selected").val() == "" ? null : $("#selectNationSearch").find("option:selected").val()},
                    {name: 'studentNo', value: $("#sNo").val() == "" ? null : $.trim($("#sNo").val())},
                    {name: 'auditStatus', value: $("#sStatus").val() == "" ? null : $.trim($("#sStatus").val())},
                    {name: 'studentName', value: $("#sName").val() == "" ? null : $.trim($("#sName").val())}
                )
                $.ajax({
                    "dataType": 'json',
                    "type": "POST",
                    "url": sSource,
                    "data": aoData,
                    "success": fnCallback
                });
            },
            "aaSorting": [[0, "desc"]],
            "bSort": false,
            "aoColumns": [
                {"sClass": "center", "bSortable": false,"mData":
                    function (data) {
                        var studentDetail = "";
                        if(data.studentNo.indexOf('TY') == 0){
                            studentDetail = '<a class="blue" href="javascript:void(0);" onclick="toChannelStudentDetail(\'' + data.studentNo + '\')">' + data.studentNo + '</a>';
                        }else{
                            studentDetail = '<a class="blue" href="javascript:void(0);" onclick="toStudentDetail(\'' + data.studentNo + '\')">' + data.studentNo + '</a>';
                        }

                        return studentDetail;
                    }
                },
                {"sClass": "center", "bSortable": false,"mData": "studentName"},
                {"sClass": "center", "bSortable": false,"mData": "nationName"},
                {"sClass": "center", "bSortable": false,"mData": "salesConsultant"},
                {"sClass": "center", "bSortable": false,"mData": "copyOperator"},
                {"sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        if(data.signDate == null || data.signDate == ""){
                            return null
                        }else {
                            return getTimeString(new Date(data.signDate))
                        }
                    }
                },
                {"sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        if (data.reason == 1){
                            return "单文书结案";
                        }
                        else if (data.reason == 2){
                            return "单申请结案";
                        }
                        else if (data.reason == 3){
                            return "其他";
                        }
                        else if (data.reason == 4){
                            return "自动结案";
                        }
                        else if (data.reason == 5){
                            return "退费结案";
                        }
                        else if (data.reason == 6){
                            return "套磁结案";
                        }
                        else if (data.reason == 7){
                            return "增值服务结案";
                        }
                        else{
                            return data.endCaseReason;
                        }
                    }
                },
                {"sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        if (data.auditStatus == 1){
                            return "已提交";
                        }
                        else if (data.auditStatus == 2){
                            return "审批中";
                        }
                        else if (data.auditStatus == 3){
                            return "审批通过";
                        }
                        else if (data.auditStatus == 4){
                            return "审批未通过";
                        }
                        else{
                            return null;
                        }
                    }
                },
                {
                    "sClass": "center", "bSortable": false, "mData":
                    function (data) {
                        var styleDiv = '<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">';
                        var check = '<a class="blue" href="javascript:void(0);" onclick="toSettle(\'' + data.studentNo + '\')">\n' +
                            '<i class="icon-zoom-in bigger-130"></i></a>\n';

                        return styleDiv + check;
                    }
                }
            ],
            "oLanguage": {
                "sLengthMenu": "每页 _MENU_条 ",
                "sZeroRecords": "对不起，查询不到任何相关数据",
                "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录 ",
                "sInfoEmpty": "显示 0 到 0 条，共 0 条记录",
                "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                "sProcessing": "正在加载中...",
                "sSearch": "搜索",
                "sUrl": "", //多语言配置文件，可将oLanguage的设置放在一个txt文件中，例：Javascript/datatable/dtCH.txt
                "oPaginate": {
                    "sFirst": "第一页",
                    "sPrevious": " 上一页 ",
                    "sNext": " 下一页 ",
                    "sLast": " 最后一页 "
                }
            }
            //多语言配置

        });

        $("#query").click(function () {
            oTable1.fnDraw();
        });
    })

    function changeTable() {
        oTable1.fnDraw()
    }

    function getTimeString(date){
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m >= 10 ? m :'0'+m;
        var d = date.getDate();
        d = d >= 10 ? d :'0'+d;
        var h = date.getHours();
        h = h >= 10 ? h :'0'+h;
        var minute = date.getMinutes();
        minute = minute >= 10 ? minute :'0'+minute;
        var second = date.getSeconds();
        second = second >= 10 ? second :'0'+second;
        return  y + '-' + m + '-' + d;
    }

    function showAttachment(showAttachment) {
        $.post("/getPrivateUrl",{"fileUrl":showAttachment},function (data,status) {
            window.open(data);
        });
    }

    //审批结案
    function toSettle(studentNo) {
        window.open("/student/settle?studentNo="+studentNo);
    }

    //跳转学生详情页
    function toStudentDetail(studentNo) {
        window.open('/student/detail?studentNo=' + studentNo);
    }

    //渠道学生详情
    function toChannelStudentDetail(studentNo) {
        window.open('/channelStudent/detail?studentNo=' + studentNo);
    }

    /*]]>*/

</script>
</body>
</html>
